import {Pipe, PipeTransform} from '@angular/core';

@Pipe({
  name: 'filter'
})
export class FilterPipe implements PipeTransform {

  transform(list: any[], filterField: string, keyword: string): any[] {
    console.log('数据流过');

    if (!filterField || !keyword) {
      return list;
    }

    return list.filter(item => item[filterField].indexOf(keyword) >= 0);
  }

}
